<%@page isELIgnored="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<div>
 <table cellspacing="0" cellpadding="0" class="table_list" style="border-top: none">
  <tbody>  
	<c:forEach items="${blogs}" var="blog">		
		<tr><td>
			<div class="listingTitle"><a class="plainLink" href="/blog.do?id=${blog.id}">${blog.title}</a></div>
			<div>by <i><b>${blog.creatorDisplayName}</b></i> on <i><b>${blog.publishDate}</b></i></div>
			<div>
				<c:choose>
					<c:when test="${fn:length(blog.body) <= 650}">
						<p>${blog.body}</p>
					</c:when>
					<c:otherwise>
						<p>${fn:substring(blog.body, 0, 650)}... [<a class="plainLink" href="/blog.do?id=${blog.id}">full text</a>]</p>										
					</c:otherwise>
				</c:choose>
			</div>
		</td></tr>		   	
   	</c:forEach>	   	
  </tbody></table>
</div>

<div class="public_paging">
      <ul>
      <c:forEach begin="1" end="${pages}" step="1" var="num">
      	<c:choose>
      		<c:when test="${num == page}">
      			<li><a class="current" href="/blogs.do?page=${num}">${num}</a></li>
      		</c:when>
      		<c:otherwise>
      			<li><a href="/blogs.do?page=${num}">${num}</a></li>
      		</c:otherwise>
      	</c:choose>
      </c:forEach>
      <c:choose>
      	<c:when test="${page lt pages}">
        	<li><a class="next" href="/blogs.do?page=${page + 1}">NEXT</a></li>
      	</c:when>
      	<c:otherwise>
      	</c:otherwise>
      </c:choose>
      </ul>
</div>